cmake_minimum_required(VERSION 3.5)
project(control_plane_v2)

# Default to C99
if(NOT CMAKE_C_STANDARD)
  set(CMAKE_C_STANDARD 99)
endif()

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(Qt5 REQUIRED COMPONENTS Widgets Core Gui)
find_package(std_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)

# Include directories
include_directories(include)

# Set UI files
set(UI_FILES
    src/control_plane.ui
)

# Use Qt's uic to generate C++ files
Qt5_wrap_ui(UIC_FILES ${UI_FILES})

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # uncomment the line when a copyright and license is not present in all source files
  #set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # uncomment the line when this package is not in a git repo
  #set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

# Add executable
add_executable(control_plane_v2 src/control_plane_v2.cpp ${UIC_FILES})

ament_target_dependencies(control_plane_v2 rclcpp std_msgs sensor_msgs)

# Specify libraries to link against
target_link_libraries(control_plane_v2 Qt5::Widgets Qt5::Core Qt5::Gui)

# Install executable
install(TARGETS control_plane_v2
  DESTINATION lib/${PROJECT_NAME})

# Install UI files
install(FILES ${UIC_FILES}
  DESTINATION share/${PROJECT_NAME}/ui
)

ament_package()
